package file.day9_18.day02;

import java.io.FileInputStream;
import java.io.IOException;
import java.nio.charset.StandardCharsets;

public class ReadStringDemo {
    public static void main(String[] args) throws IOException {
        FileInputStream fis = new FileInputStream("fos.txt");
        byte[] data = new byte[1024*10];//10kb
        String line;
        int len = fis.read(data);//将读到的字节装到字节数组中
        System.out.println("总共读取的大小"+len);//实际大小
        line = new String(data,0,len, StandardCharsets.UTF_8);//将字节数组转换成指定的字符串类型（字符集类型）
        System.out.println(line);
        System.out.println("读取到的字符串长度"+line.length());//字符串大小
        System.out.println("读取完成");

        fis.close();
    }
}
